home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
iqb9109.zip
/
QUIKDEMO.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-09-09
|
1KB
|
55 lines
' QuikDemo.Bas
' Program to demonstrate the QuickSort subprogram
' Portions Copyright by Microsoft Corporation
'
' $INCLUDE: 'QSORT.BI'
DECLARE SUB Initialize ()
' Create some random data
Initialize
' Display the unsorted keys
FOR I% = 1 TO MaxIndex
PRINT SortArray(I%).SortKey,
NEXT I%
PRINT: PRINT
' Sort the entire array
QuickSort 1, MaxIndex
' Display the sorted keys
FOR I% = 1 TO MaxIndex
PRINT SortArray(I%).SortKey,
NEXT I%
PRINT
END
' Subprogram to initialize the sort array keys to random values
' This is a modified version of the Initialize routine from the
' SORTDEMO.BAS program supplied with QuickBASIC 4.5. Note that if
' you modify the SortType to be a non-string data type, you must
' change the lines below that construct a string version of the
' random key and the line which assigns the string version of the
' random key value to the sort key. However, for a real-world usage,
' of course, you won't need this Initialize subprogram.
SUB Initialize STATIC
RANDOMIZE TIMER ' Seed the random-number generator.
FOR I% = 1 TO MaxIndex
RandKey$ = ""
FOR J% = 1 TO 5
RandVal% = RandInt%(65, 90)
PRINT RandVal%
RandKey$ = RandKey$ + CHR$(RandVal%)
NEXT J%
LSET SortArray(I%).SortKey = RandKey$
NEXT I%
END SUB